package br.com.fafica.fast_restaurant.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JButton;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JSeparator;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.Color;

public class TelaPrincipal extends JFrame {
	
			public void run() {
				try {
					TelaPrincipal frame = new TelaPrincipal();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}

	public TelaPrincipal() {
		setTitle("TELA PRINCIPAL");
		setBackground(new Color(255, 255, 255));
		final TelaPrincipal estaTela = this;
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 804, 600);
		JPanel contentPane = new JPanel();
		contentPane.setBackground(new Color(255, 255, 255));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		panel.setBackground(new Color(255, 255, 255));
		
		JButton btnMesa = new JButton("Mesa");
		btnMesa.setForeground(new Color(255, 215, 0));
		btnMesa.setBackground(new Color(0, 100, 0));
		btnMesa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				TelaMesas telaMesas = new TelaMesas();
				telaMesas.setVisible(true);
				estaTela.setVisible(false);
				
			}
		});
		
		JButton btnCaixa = new JButton("Caixa");
		btnCaixa.setForeground(new Color(255, 215, 0));
		btnCaixa.setBackground(new Color(0, 100, 0));
		btnCaixa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				TelaCaixa telaCaixa = new TelaCaixa();
				telaCaixa.setVisible(true);
				estaTela.setVisible(false);
				
			}
		});
		
		JButton btnSair = new JButton("Sair");
		btnSair.setForeground(new Color(255, 215, 0));
		btnSair.setBackground(new Color(0, 100, 0));
		btnSair.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				estaTela.dispose();
			}
		});
		
		JButton btnNewButton = new JButton("Pesquisar");
		btnNewButton.setForeground(new Color(255, 215, 0));
		btnNewButton.setBackground(new Color(0, 100, 0));
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				TelaPesquisar telaPesquisar = new TelaPesquisar();
				telaPesquisar.setVisible(true);
				estaTela.setVisible(false);
			}
		});
		
		JButton btnCadastro = new JButton("Cadastro");
		btnCadastro.setForeground(new Color(255, 215, 0));
		btnCadastro.setBackground(new Color(0, 100, 0));
		btnCadastro.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				TelaCadastro telaCadastro = new TelaCadastro();
				telaCadastro.setVisible(true);
				estaTela.setVisible(false);
				
			}
		});
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addComponent(btnCadastro)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnMesa)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnCaixa)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(btnNewButton)
					.addPreferredGap(ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
					.addComponent(btnSair, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE))
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_panel.createSequentialGroup()
					.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnCadastro, GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
						.addComponent(btnMesa, GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
						.addComponent(btnCaixa, GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
						.addComponent(btnNewButton, GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE)
						.addComponent(btnSair, GroupLayout.DEFAULT_SIZE, 44, Short.MAX_VALUE))
					.addContainerGap())
		);
		panel.setLayout(gl_panel);
		
		JLabel label = new JLabel("");
		label.setHorizontalAlignment(SwingConstants.TRAILING);
		label.setVerticalAlignment(SwingConstants.BOTTOM);
		label.setIcon(new ImageIcon(TelaPrincipal.class.getResource("/ICONES_WALLPAPERS/SLOGAN_FINAL.jpg")));
		
		JSeparator separator = new JSeparator();
		separator.setBackground(new Color(255, 255, 255));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.TRAILING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addComponent(panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
						.addComponent(separator, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
						.addComponent(label, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 778, Short.MAX_VALUE))
					.addContainerGap())
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(separator, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
					.addGap(3)
					.addComponent(label, GroupLayout.PREFERRED_SIZE, 489, Short.MAX_VALUE))
		);
		contentPane.setLayout(gl_contentPane);
	}
}
